
#pragma once

#include "dsegen.h"
#include "FindNeighbor.h"

namespace dhis
{
	class CImageInfo
	{
	public:
		CImageInfo();
		~CImageInfo();
	public:
		bool  ReadImageInfoFromFile(const char* szFile);
	public:
		inline bool IsValid() const { return m_isValid; }
		inline int RasterBandCount() const { return m_numBands; }
		inline int RasterXSize() const { return m_xsize; }
		inline int RasterYSize() const { return m_ysize; }

		inline REAL XOffset() const { return m_geoTrans[0]; }
		inline REAL YOffset() const { return m_geoTrans[3]; }
		inline REAL XGSD() const { return m_geoTrans[1]; }
		inline REAL YGSD() const { return m_geoTrans[5]; }
		inline REAL PixelArea() const { return m_pixelArea; }

		inline bool GeoTransformFlag() const { return m_geoTransFlag; }
		inline const char*ProjectionRef() const { return m_szProjection.c_str(); }

		inline REAL BandMinValue(const int& band) const { return m_minValue[band]; }
		inline REAL BandMaxValue(const int& band) const{ return m_maxValue[band]; }
		inline REAL BandMeanValue(const int& band) const { return m_meanValue[band]; }
		inline REAL BandStdDevValue(const int& band) const { return m_stdDevValue[band]; }
		inline REAL MaxBandStdDevValue() const { return m_maxStdDev; }

		inline bool BandScaleFlag(const int& band) const { return m_scaleValueFlag[band]; }
		inline REAL BandScale(const int& band) const { return m_scaleValue[band]; }

		inline bool BandOffsetFlag(const int& band) const { return m_offsetValueFlag[band]; }
		inline REAL BandOffset(const int& band) const { return m_offsetValue[band]; }
		

		inline bool BandNoDataValueFlag(const int& band) const { return m_nodataValueFlag[band]; }
		inline REAL BandNoDataValue(const int& band) const { return m_nodataValue[band]; }

		const char* ImageFileName() const { return m_szFileName.c_str(); }

		REAL GetMapX(const int& col) const;
		REAL GetMapY(const int& row) const;
	private:
		bool m_isValid;
		std::string m_szFileName;
		int m_xsize;
		int m_ysize;
		int m_numBands;
		bool m_geoTransFlag;
		double m_geoTrans[6];
		std::string   m_szProjection;
		REAL m_pixelArea;

		REAL         m_maxStdDev;
		REALVec   m_minValue;
		REALVec   m_maxValue;
		REALVec   m_meanValue;
		REALVec   m_stdDevValue;

		BoolVec   m_scaleValueFlag;
		REALVec   m_scaleValue;

		BoolVec   m_offsetValueFlag;
		REALVec   m_offsetValue;
		
		BoolVec   m_nodataValueFlag;
		REALVec   m_nodataValue;
	};
}
